﻿var storeMenuCleaner;
var storeMenuCleanerTeam = createStoreMenuCleanerTeam();
var storeSettingToiletCleaner = createSettingToiletCleaner();
var storeMenuTemporaryMission = createMenuTemporaryMission();
var storeMenuJobFeedback = createMenuJobFeedback();
var storeMenuAttendanceInfo = createMenuAttendanceInfo();
var storeMenuToiletWorkInfo = createMenuToiletWorkInfo();
/* ---菜单  考勤记录1---*/
function menuToiletWorkInfoData() {
    storeMenuToiletWorkInfo.load({
        params: { clientNo: userClientNo, date: "2020-03-25", name: "", op: 'GetMenuToiletWorkInfo' }
    });
}
function menuToiletWorkInfo() {
    var this_grid = new Ext.grid.GridPanel({
        columns: [
	{ header: "姓名", dataIndex: "name", width: 60 },
    { header: "公厕名称", dataIndex: "toiletName", width: 100 },
	{ header: "开始时间", dataIndex: "time", width: 100 },
    { header: "结束时间", dataIndex: "workAround", width: 100 },
    { header: "持续时间", dataIndex: "amIN", width: 100 },
    { header: "男女厕", dataIndex: "sex", width: 100 }
	],
        store: storeMenuToiletWorkInfo
    });

    var panel = new Ext.Panel({
        layout: 'fit',
        items: this_grid
    });

    menuToiletWorkInfoData();
    var window = new Ext.Window({
        title: '公厕作业记录',
        layout: 'fit',       //弹出窗口内布局会充满整个窗口;
        width: 500,          //设置窗口大小;
        height: 300,
        items: panel         //默认会生成Ext.Panel类型的对象;并且随窗口大小改变而改变;
    });
    window.show();
}
/* ---菜单  考勤记录2---*/
function menuAttendanceInfoData() {
    storeMenuAttendanceInfo.load({
        params: { clientNo: userClientNo, date: "2020-03-25", statue: "", op: 'GetMenuAttendanceInfo' }
    });
}
function menuAttendanceInfo() {
    var this_grid = new Ext.grid.GridPanel({
        columns: [
	{ header: "姓名", dataIndex: "name", width: 60 },
    { header: "清运队", dataIndex: "clientName", width: 100 },
	{ header: "班组", dataIndex: "clientName2", width: 100 },
    { header: "作业范围", dataIndex: "workAround", width: 100 },
    { header: "上午签入", dataIndex: "amIN", width: 100 },
    { header: "上午签出", dataIndex: "amOUT", width: 100 },
    { header: "下午签入", dataIndex: "pmIN", width: 100 },
    { header: "下午签出", dataIndex: "pmOUT", width: 100 }
	],
        store: storeMenuAttendanceInfo
    });

    var panel = new Ext.Panel({
        layout: 'fit',
        items: this_grid
    });

    menuAttendanceInfoData();
    var window = new Ext.Window({
        title: '考勤记录',
        layout: 'fit',       //弹出窗口内布局会充满整个窗口;
        width: 500,          //设置窗口大小;
        height: 300,
        items: panel         //默认会生成Ext.Panel类型的对象;并且随窗口大小改变而改变;
    });
    window.show();
}

/* ---菜单  反馈记录---*/
function menuJobFeedbackData() {
    storeMenuJobFeedback.load({
        params: { clientNo: userClientNo, op: 'GetMenuJobFeedback' }
        , callback: function (records, options, success) {
            if (success && records.length) {
//                SettingToiletCleanerWindow(this);
            }
        }
    });
}
function menuJobFeedback() {
    var this_grid = new Ext.grid.GridPanel({
        columns: [
	{ header: "班组编号", dataIndex: "clientNo", width: 100 },
    { header: "时间", dataIndex: "time", width: 130 },
	{ header: "道路", dataIndex: "roadName", width: 60 },
    { header: "位置", dataIndex: "location", width: 200 },
//    { header: "详情", dataIndex: "detail", width: 100 }
	],
        store: storeMenuJobFeedback
    });

    var panel = new Ext.Panel({
        layout: 'fit',
        items: this_grid
    });

    menuJobFeedbackData();
    var window = new Ext.Window({
        title: '反馈记录信息列表',
        layout: 'fit',       //弹出窗口内布局会充满整个窗口;
        width: 500,          //设置窗口大小;
        height: 300,
        items: panel         //默认会生成Ext.Panel类型的对象;并且随窗口大小改变而改变;
    });
    window.show();
}

/* ---菜单  临时任务---*/
function menuTemporaryMissionData() {
    storeMenuTemporaryMission.load({
        params: { clientNo: userClientNo, op: 'GetMenuTemporaryMission' }
    });
}
function menuTemporaryMission() {
    var this_grid = new Ext.grid.GridPanel({
        columns: [
	{ header: "任务时间", dataIndex: "missionDate", width: 60 },
    { header: "任务公厕", dataIndex: "missionToilet", width: 100 },
	{ header: "任务地点", dataIndex: "missionAD", width: 100 },
    { header: "负责机构", dataIndex: "clientName", width: 100 },
    { header: "任务状态", dataIndex: "missionStatus", width: 100 },
    { header: "任务要求", dataIndex: "missionAsk", width: 100 }
	],
        store: storeMenuTemporaryMission
    });

    var panel = new Ext.Panel({
        layout: 'fit',
        items: this_grid
    });

    menuTemporaryMissionData();
    var window = new Ext.Window({
        title: '临时任务',
        layout: 'fit',       //弹出窗口内布局会充满整个窗口;
        width: 500,          //设置窗口大小;
        height: 300,
        items: panel         //默认会生成Ext.Panel类型的对象;并且随窗口大小改变而改变;
    });
    window.show();
}


/* ---菜单  作业公厕设定1---*/
function SettingToiletCleaner(clientName, date, type, name) {
    storeSettingToiletCleaner.load({
        params: { clientNo: userClientNo, op: 'GetMenuSetCleanerList'}//区名、日期、中转站or处理厂、中转站类型or处理厂类型
                    , callback: function (records, options, success) {
                        if (success && records.length) {
                            SettingToiletCleanerWindow(this);
                        }
                    }
    });
}
function SettingToiletCleanerWindow(item) {
    var this_grid = new Ext.grid.GridPanel({
        columns: [
	{ header: "序号", dataIndex: "vid", width: 60 },
    { header: "姓名", dataIndex: "name", width: 100 },
	{ header: "所属机构", dataIndex: "clientName", width: 100 },
    { header: "维护公厕", dataIndex: "ToiletName", width: 100 },
    { header: "维护开始时间", dataIndex: "startDate", width: 100 },
    { header: "维护结束时间", dataIndex: "endDate", width: 100 },
    { header: "设置时间", dataIndex: "settingDate", width: 100 }
	],
        store: storeSettingToiletCleaner
    });

    var panel = new Ext.Panel({
        layout: 'fit',
        items: this_grid
    });
    var window = new Ext.Window({
        title: '人员作业公厕',
        layout: 'fit',       //弹出窗口内布局会充满整个窗口;
        width: 500,          //设置窗口大小;
        height: 300,
        items: panel         //默认会生成Ext.Panel类型的对象;并且随窗口大小改变而改变;
    });
    window.show();
}

/* ---菜单  作业公厕设定2---*/
function SettingToiletWork(clientName, date, type, name) {
    var weightVehicleInfoNew = new Ext.data.Store({
        url: "./Json/JsonGetToiletInfoList.ashx",
        reader: new Ext.data.JsonReader(
                { root: 'data' },
                Ext.data.Record.create([{ name: 'vid' }, { name: 'ToiletName' }, { name: 'clientName' }, { name: 'peopleNames' }])
            )
    });
    weightVehicleInfoNew.load({
        params: { clientNo: userClientNo, op: 'GetMenuSetToiletList'}//区名、日期、中转站or处理厂、中转站类型or处理厂类型
                    , callback: function (records, options, success) {
                        if (success && records.length) {
                            SettingToiletWorkWindow(this);
                        }
                    }
    });
}
function SettingToiletWorkWindow(item) {
    var this_grid = new Ext.grid.GridPanel({
        columns: [
	{ header: "序号", dataIndex: "vid", width: 60 },
    { header: "公厕名称", dataIndex: "ToiletName", width: 100 },
	{ header: "所属机构", dataIndex: "clientName", width: 100 },
    { header: "负责维护人员", dataIndex: "peopleNames", width: 300 }
	],
        store: item
    });

    var panel = new Ext.Panel({
        layout: 'fit',
        items: this_grid
    });
    var window = new Ext.Window({
        title: '公厕作业人员查询',
        layout: 'fit',       //弹出窗口内布局会充满整个窗口;
        width: 500,          //设置窗口大小;
        height: 300,
        items: panel         //默认会生成Ext.Panel类型的对象;并且随窗口大小改变而改变;
    });
    window.show();
}

/* ---菜单  人员管理---*/
function menuCleanerTitleView() {
    storeMenuCleanerTeam.load({ params: { clientNo: userClientNo, op: 'GetMenuCleanerTeam'} });
    return new Ext.Panel({
        labelAlign: 'top',
        frame: true,
        //title: '查询条件',
        bodyStyle: 'padding:0px 0px 0',
        anchor: '100% 15.5%',
        //width: 720,
        items: [{
            layout: 'column',
            items: [{
                columnWidth: .3,
                layout: { type: 'hbox' },
                items: [{ xtype: "label", width: 40, text: '姓名：' }, { xtype: 'textfield', width: 100, id: "textfieldName"}]
            },
                {
                    columnWidth: .5,
                    layout: { type: 'hbox' },
                    items: [{ xtype: "label", width: 60, text: '组织机构：' },
                        inicmbCleanerTeam()
                    ]
                },
                {
                    columnWidth: .2,
                    layout: 'form',
                    items: [
                        { xtype: "label", id: "menuCleanerCount" }
                    ]
                }]
        }],
        buttons: [{
            text: "查询",
            handler: menuCleanerData
        }
//        , {
//            text: "增加",
//            handler: menuCleanerDataADD
//        }, {
//            text: "删除",
//            handler: menuCleanerDataDelete
//        }
        ]
    });
}

function menuCleanerDataADD() {}
function menuCleanerDataDelete() {}
function menuCleanerData() {
    var para_clientNo = userClientNo;
    var para_name = "";
    if (Ext.get('cmbToiletMenu_CleanerTeam')) {
        para_clientNo = Ext.getCmp('cmbToiletMenu_CleanerTeam').getValue();
    }
    if (Ext.get('textfieldName')) {
        para_name = Ext.getCmp('textfieldName').getValue();
    }
    storeMenuCleaner.load({
        params: { clientNo: para_clientNo, name: para_name, op: 'GetMenuCleanerList'}//区名、日期、中转站or处理厂、中转站类型or处理厂类型
        , callback: function (records, options, success) {
            Ext.getCmp("menuCleanerCount").setText("记录数：" + records.length + "条");
        }
    });
}

function menuCleaner() {
    storeMenuCleaner = new Ext.data.Store({
        url: "./Json/JsonGetToiletInfoList.ashx",
        reader: new Ext.data.JsonReader(
                { root: 'data' },
                Ext.data.Record.create([{ name: 'name' }, { name: 'simNO' }, { name: 'clientNO' }, { name: 'sex' }, { name: 'phone' }, { name: 'worktype' }, { name: 'birthDay' }, { name: 'workDay' }])
            )
    });

    var this_grid = new Ext.grid.GridPanel({
        anchor: '100% 85%',
        columns: [
	{ header: "姓名", dataIndex: "name", width: 60 },
    { header: "通讯卡号", dataIndex: "simNO", width: 130 },
	{ header: "组织编号", dataIndex: "clientNO", width: 100 },
    { header: "性别", dataIndex: "sex", width: 40 },
    { header: "电话", dataIndex: "phone", width: 80 },
	{ header: "工种", dataIndex: "worktype", width: 80 }, 
    { header: "生日", dataIndex: "birthDay", width: 100 },
	{ header: "入职时间", dataIndex: "workDay", width: 100 }
	],
        store: storeMenuCleaner
    });
    var panel = new Ext.Panel({
        layout: 'anchor',
        items: [menuCleanerTitleView(), this_grid]
    });
    menuCleanerData();
    var window = new Ext.Window({
        title: '人员信息列表',
        layout: 'fit',       //弹出窗口内布局会充满整个窗口;
        width: 700,          //设置窗口大小;
        height: 500,
        items: panel         //默认会生成Ext.Panel类型的对象;并且随窗口大小改变而改变;
    });
    window.show();
}

function inicmbCleanerTeam() {
    var box = new Ext.form.ComboBox({
        fieldLabel: '组织机构',
        id: 'cmbToiletMenu_CleanerTeam',
        width: 150,
        //        labelWidth: 20, 
        allowBlank: false,
        triggerAction: "all", //是否开启自动查询功能
        store: storeMenuCleanerTeam, //定义数据源
        displayField: "CLIENT_NAME", //关联某一个逻辑列名作为显示值
        valueField: "CLIENT_NO",
        hiddenName: "CLIENT_NO_hiddenName", //关联某一个逻辑列名作为实际值
        mode: "local", //如果数据来自本地用local 如果来自远程用remote默认为remote
        emptyText: "请选择组织机构"//没有选择时候的默认值
    });
    Ext.getCmp("cmbToiletMenu_CleanerTeam").setValue(userName);
    return box;
}

function createMenuTemporaryMission() {
    return new Ext.data.Store({
        url: "./Json/JsonGetToiletInfoList.ashx",
        reader: new Ext.data.JsonReader(
                { root: 'data' },
                Ext.data.Record.create([{ name: 'missionDate' }, { name: 'missionToilet' }, { name: 'missionAD' }, { name: 'clientName' }, { name: 'missionStatus' }, { name: 'missionAsk' }])
            )
    });
}

/* ---数据  Store格式---*/
function createSettingToiletCleaner() {
    return new Ext.data.Store({
        url: "./Json/JsonGetToiletInfoList.ashx",
        reader: new Ext.data.JsonReader(
                { root: 'data' },
                Ext.data.Record.create([{ name: 'vid' }, { name: 'name' }, { name: 'ToiletName' }, { name: 'clientName' }, { name: 'startDate' }, { name: 'endDate' }, { name: 'settingDate'}])
            )
    });
}

function createMenuJobFeedback() {
    return new Ext.data.Store({
        url: "./Json/JsonGetToiletInfoList.ashx",
        reader: new Ext.data.JsonReader(
                { root: 'data' },
                Ext.data.Record.create([{ name: 'clientNo' }, { name: 'time' }, { name: 'roadName' }, { name: 'location' }, { name: 'detail' }])
            )
    });
}
function createMenuAttendanceInfo() {
    return new Ext.data.Store({
        url: "./Json/JsonGetToiletInfoList.ashx",
        reader: new Ext.data.JsonReader(
                { root: 'data' },
                Ext.data.Record.create([{ name: 'name' }, { name: 'clientName' }, { name: 'clientName2' }, { name: 'workAround' }, { name: 'amIN' }, { name: 'amOUT' }, { name: 'pmIN' }, { name: 'pmOUT'}])
            )
    });
}

function createMenuToiletWorkInfo() {
    return new Ext.data.Store({
        url: "./Json/JsonGetToiletInfoList.ashx",
        reader: new Ext.data.JsonReader(
                { root: 'data' },
                Ext.data.Record.create([{ name: 'name' }, { name: 'time' }, { name: 'toiletName' }, { name: 'sex' }])
            )
    });
}

function createStoreMenuCleanerTeam() {
    return new Ext.data.Store({
        url: "./Json/JsonGetToiletInfoList.ashx",
        autoLoad: true,
        reader: new Ext.data.JsonReader(
                { root: 'data' },
                Ext.data.Record.create([{ name: 'CLIENT_NO' }, { name: 'CLIENT_NAME'}])
            )
    });
}